package com.demo.hotel_book.service;

import com.demo.hotel_book.mapper.HotelOrderMapper;
import com.demo.hotel_book.entity.Hotel;
import com.demo.hotel_book.entity.HotelOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelOrderService {
    @Autowired
    private HotelOrderMapper orderMapper;

    public Hotel findById(Integer id) {
        return orderMapper.findById(id);
    }

    public void insertOrder(HotelOrder hotelOrder) {
        orderMapper.insertOrder(hotelOrder);
    }

    List<HotelOrder> findByUserId(int userId){
        return orderMapper.findByUserId(userId);
    }

    public HotelOrder findByOrderId(Integer id) {
        return orderMapper.findByOrderId(id);
    }

    public Hotel findHotelByOrderId(Integer id) {
        return orderMapper.findHotelByOrderId(id);
    }

    public Integer deleteOrder(Integer id) {
        return orderMapper.deleteOrder(id);
    }

    public String ifPay(boolean ifPayed) {
        if (ifPayed) {
            return "已支付";
        } else
            return "未支付";

    }

//    public boolean findByUserId(int userId) {
//        return orderMapper.findByUserId(userId);
//    }
}
